import Vue from 'vue'
import * as Sentry from '@sentry/browser'
import { Integrations as ApmIntegrations } from '@sentry/apm'
import { Vue as VueIntegration } from '@sentry/integrations'

const {
  VUE_APP_TITLE,
  VUE_APP_SENTRY_DOMAIN,
  VUE_APP_SENTRY_PROJECTID,
  VUE_APP_SENTRY_PUBLIC_KEY
} = process.env

if (!VUE_APP_TITLE.includes('dev')) {
  Sentry.init({
    environment: VUE_APP_TITLE,
    dsn: `${location.protocol}//${VUE_APP_SENTRY_PUBLIC_KEY}@${VUE_APP_SENTRY_DOMAIN}/${VUE_APP_SENTRY_PROJECTID}`,
    integrations: [
      new VueIntegration({ Vue, attachProps: true }),
      new ApmIntegrations.Tracing()
    ],
    // eslint-disable-next-line
    // release: VUE_APP_SENTRY_RELEASE,
    tracesSampleRate: 1.0 // Be sure to lower this in production
  })
}

export default Sentry
